import * as types from './mutation-types';
import _ from "lodash";
const matutaions = {
  [types.SET_SINGER](state, singer) {
    state.singer = singer
  },
  [types.SET_LOGIN](state,login){
    state.login = login
  },
  [types.SET_GOODSTYPES_LIST](state,list){
    state.goodsTypes.list = list
  },
  [types.SET_GOODS_INDEX](state,index){
    state.goodsTypes.active = index;
  },
  [types.SET_DRAWER_STATE](state,drawer_state){
    state.drawer.state = drawer_state
  },
  [types.SET_COMMON_LOADING](state,common_loading){
    state.common.loading = common_loading;
  },
  [types.SET_COMMON_HEADER](state,common_header){
    state.common.headerState = common_header;
  },
  [types.SET_SETTING_SELECTEDLIST](state,set_setting_selectedlist){
    state.setting.selectedList = set_setting_selectedlist
  },
  [types.PUSH_SETTING_SELECTEDLIST](state,item){
    state.setting.selectedList.push(item);
  },
  [types.DELETE_SETTING_SELECTEDLIST](state,itemId){
     let index = _.findIndex(state.setting.selectedList,{id:itemId});
     state.setting.selectedList.splice(index,1)
  },
  [types.SET_CLASSIFY_MODE](state,val){
    state.classify.mode = val;
  },
  [types.SET_USER_PHONE](state,val){
    state.userData.phone = val
  },
  [types.SET_USER_ICON](state,val){
    state.userData.icon = val;
  },
  [types.SET_USER_NAME](state,val){
    state.userData.name = val;
  },
  [types.SET_USER_ISAGENCY](state,val){
    state.userData.isAgency = val;
  },
  [types.SET_USER_ID](state,val){
    state.userData.id = val;
  },
  [types.SWITCH_HEADER_FILTER](state){
    state.header.filter++;
  },
  [types.ADD_GOODSSHARELIST](state,val){
    let Juge = true
    _.each(state.goodsShareList,(goods)=>{
        if(goods.info.id === val.info.id){
            Juge = false
        }
    });
    Juge?state.goodsShareList.push(val):null;
  },
  [types.SET_COMMON_REGION](state,val){
     state.common.region = val;
  }
};
export default matutaions
